package com.yuzhitong.shapi.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import org.jetbrains.annotations.NotNull;

/**
 * Created by Brsya
 * CreateDate: 2022/4/5  18:29
 * Description:
 * 自定义下拉刷新组件
 */
public class MySwipeRefreshLayout extends SwipeRefreshLayout {

    private MyWebView webView;


    public MySwipeRefreshLayout(@NonNull @NotNull Context context) {
        super(context);
    }

    public MySwipeRefreshLayout(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyWebView getWebView() {
        return webView;
    }

    public void setWebView(MyWebView webView) {
        this.webView = webView;
    }

    @Override
    public boolean canChildScrollUp() {
        if (webView != null) {
//            return !webView.isTop() && webView.isScrollCan();
            return webView.getScrollY() > 0;
        }
        return super.canChildScrollUp();
    }
}
